package com.deyuanyun.pic.ctrl.enumeration;

import com.deyuanyun.pic.ctrl.annotation.AutoEnum;

/**
 * 直流干扰源类型
 *
 * @author scalpel.王敏
 * @version [v1.0] 创建时间（2016/9/12）
 * @see // 引用的类
 * Method List:
 * 1.----------------
 * 2.----------------
 * History:
 */
@AutoEnum(name="直流干扰源类型",method = "getVal")
public enum InterferenceSourceTypeEnum {

    HVDCTS("高压直流输电系统"),
    DCTS("直流牵引系统"),
    OCPS("其他阴极保护系统"),
    ODEF("其他直流用电设施");

    private String label;

    private InterferenceSourceTypeEnum(String label) {
        this.label = label;
    }

    public String getLabel() {
        return label;
    }

    public static String getVal(String lable)
    {

        InterferenceSourceTypeEnum  rs[]=InterferenceSourceTypeEnum.values();
        for(int i=0,end=rs.length;i<end;i++)
        {
            if(rs[i].getLabel().equals(lable))
            {
                return rs[i].toString();
            }
        }
        return null;
    }

    public static String getLabelBycode(String code) {
        InterferenceSourceTypeEnum rs[] = InterferenceSourceTypeEnum.values();
        for (int i = 0; i < rs.length; i++) {
            if (rs[i].toString().equals(code)) {
                return rs[i].getLabel();
            }
        }
        return null;
    }

   public static boolean containsCode(String code) {
        InterferenceSourceTypeEnum rs[] = InterferenceSourceTypeEnum.values();
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < rs.length; i++) {
            sb.append(rs[i].toString()).append(",");
        }
        sb.deleteCharAt(sb.length() - 1);
        return  sb.toString().contains(code);
    }

}
